package com.liuweiheng.springcloud.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Gateway网关路由配置中心
 *
 * @author kasuganosora
 * @since 2020/10/29 16:52
 */
@Configuration
public class GateWayConfig {
    @Bean
    public RouteLocator customRouteLocator(RouteLocatorBuilder routeLocatorBuilder) {

        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();

        routes.route("BAIDU_NEWS",
                r -> r.path("/guonei")
                        .uri("http://news.baidu.com/guonei")
        ).build();

        return routes.build();
    }
}
